@@ -1,6 +1,14 @@ |
||
| 1 | 1 |
class UserMailer < ActionMailer::Base |
| 2 | 2 |
default from: "contact@website.com" |
| 3 | 3 |
|
| 4 |
+ def signup_message(user) |
|
| 5 |
+ config = Info.first |
|
| 6 |
+ mail :to => user.email, |
|
| 7 |
+ :subject => ("Welcome to "+ config.website_name),
|
|
| 8 |
+ :from => config.contact_email, |
|
| 9 |
+ :from_name => config.website_name, |
|
| 10 |
+ :body => ("Thanks for registering to our website. " + config.website_link)
|
|
| 11 |
+ end |
|
| 4 | 12 |
|
| 5 | 13 |
def contact_message(contact_message, to_address) |
| 6 | 14 |
@msg = contact_message |
@@ -18,6 +18,7 @@ class User < ActiveRecord::Base |
||
| 18 | 18 |
|
| 19 | 19 |
after_create do |
| 20 | 20 |
subscribe_user |
| 21 |
+ send_signup_mail |
|
| 21 | 22 |
end |
| 22 | 23 |
|
| 23 | 24 |
def subscribe_user |
@@ -26,4 +27,9 @@ class User < ActiveRecord::Base |
||
| 26 | 27 |
end |
| 27 | 28 |
end |
| 28 | 29 |
|
| 30 |
+ |
|
| 31 |
+ def send_signup_mail |
|
| 32 |
+ UserMailer.signup_message(self).deliver |
|
| 33 |
+ end |
|
| 34 |
+ |
|
| 29 | 35 |
end |
@@ -55,6 +55,11 @@ Then(/^I log in with the email "(.*?)" and password "(.*?)"$/) do |arg1, arg2| |
||
| 55 | 55 |
page.driver.submit :post, new_user_session_path(:user => {email: arg1, password: arg2}), {}
|
| 56 | 56 |
end |
| 57 | 57 |
|
| 58 |
+When(/^I submit the login form$/) do |
|
| 59 |
+ click_button "Submit" |
|
| 60 |
+ page.driver.submit :post, user_registration_path(:user => {first_name: "Monty", last_name: "Cantsin", email: "monty_cantsin@canada.com", password: "12345678", password_confirmation: "12345678"}), {}
|
|
| 61 |
+end |
|
| 62 |
+ |
|
| 58 | 63 |
# METHODS |
| 59 | 64 |
|
| 60 | 65 |
def user_login |
@@ -10,6 +10,9 @@ module NavigationHelpers |
||
| 10 | 10 |
when/the login page/ |
| 11 | 11 |
visit new_user_session_path |
| 12 | 12 |
|
| 13 |
+ when/the signup page/ |
|
| 14 |
+ visit new_user_registration_path |
|
| 15 |
+ |
|
| 13 | 16 |
when/the admin dashboard/ |
| 14 | 17 |
visit admin_dashboard_path |
| 15 | 18 |
|
@@ -23,4 +23,18 @@ Feature: User Account |
||
| 23 | 23 |
When I go to the login page |
| 24 | 24 |
And I log in with the email "monty_cantsin@canada.com" and password "12345678" |
| 25 | 25 |
Then I click in the link "Logout" |
| 26 |
- And I should see "Signed out successfully" |
|
| 26 |
+ And I should see "Signed out successfully" |
|
| 27 |
+ |
|
| 28 |
+ Scenario: User registration |
|
| 29 |
+ Given I am not logged in |
|
| 30 |
+ And I go to the signup page |
|
| 31 |
+ When I fill in "First Name" with "Monty" |
|
| 32 |
+ And I fill in "Last Name" with "Cantsin" |
|
| 33 |
+ And I fill in "Email" with "monty_cantsin@canada.com" |
|
| 34 |
+ And I fill in "Password" with "12345678" |
|
| 35 |
+ And I fill in "Password Confirmation" with "12345678" |
|
| 36 |
+ And I submit the login form |
|
| 37 |
+ Then I should see "Welcome! You have signed up successfully" |
|
| 38 |
+ And I should see "Monty Cantsin" |
|
| 39 |
+ And I should see "Logout" |
|
| 40 |
+ And "monty_cantsin@canada.com" should receive an email with subject "Welcome to Rails Website Template" |